import gmemsess

class User(object):
    """Get's the current user_id from the session
       user_id is of type int
    """
    @staticmethod
    def get_current_user_id(req_handler):
        session=gmemsess.Session(req_handler)
        return session['user_id'] if 'user_id' in session else None

    @staticmethod
    def get_current_user_name(req_handler):
        session=gmemsess.Session(req_handler)
        return session['user_name'] if 'user_name' in session else None
    
    """Set's the current user_id from the sessoin
       user_id is of type int
    """
    @staticmethod
    def set_current_user(req_handler, user_id, user_name):
        session=gmemsess.Session(req_handler)
        session['user_id'] = user_id
        session['user_name'] = user_name
        session.save()
